package tw.com.diary.db.domain;

import tw.com.diary.ae.com.DirayBussinessException;
import tw.com.diary.ae.com.Msg;
import android.text.TextUtils;

public class PaserUtils {
	private static String SHOW_DATE = "%04d/%02d/%02d";

	public static String getShowDate(String date) {
		if (TextUtils.isEmpty(date)) {
			return String.format(SHOW_DATE, 0, 0, 0);
		}
		if (date.length() == 8) {
			final String year = date.substring(0, 4);
			final String mon = date.substring(4, 6);
			final String day = date.substring(6);

			return String.format(SHOW_DATE, Integer.parseInt(year), Integer.parseInt(mon), Integer.parseInt(day));
		}
		throw new DirayBussinessException(Msg.E0001, "時間格式錯誤");
	}
}
